<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    
</head>
<body>
    <button>发送请求</button>
    <script>
        let oBtn = document.querySelector('button');
        // 配置基础路径及超时时间,弊端基础路径只能配置一个
        axios.defaults.baseURL = 'http://localhost:8080'
        axios.defaults.timeout = 20000;

        oBtn.onclick = function(){
            axios.get('/timeout').then(response=>response.data)
            .then(data=>{
                console.log('data: ', data);
            })
        }
    </script>
</body>
</html>